package com.vm.utils;

import android.annotation.SuppressLint;

public class SoftDataUtil {
	static String download;

	public static String getSoftDownload(int number) {
		if (number > 10000) {
			download = Integer.toString(number / 10000) + "."
					+ Integer.toString((number % 10000) / 1000) + "万";
		} else if (number > 100000000) {
			download = Integer.toString(number / 100000000) + "."
					+ Integer.toString((number % 100000000) / 10000000) + "亿";
		} else {
			download = Integer.toString(number);
		}
		return download;
	}

	@SuppressLint("DefaultLocale")
	public static String formatSize(float size) {
		long kb = 1024;
		long mb = (kb * 1024);
		long gb = (mb * 1024);
		if (size < kb) {
			return String.format("%d B", (int) size);
		} else if (size < mb) {
			return String.format("%.2f KB", size / kb); // 保留两位小数
		} else if (size < gb) {
			return String.format("%.2f MB", size / mb);
		} else {
			return String.format("%.2f GB", size / gb);
		}
	}
}